import axios from "axios";
const instance = axios.create({
  baseURL: "http://localhost:8080",
  timeout: 5000,
});

instance.interceptors.response.use(
  (response) => {
    if (response.status === 200) {
      return response.data;
    } else {
      console.error("请求失败");
      return Promise.reject("请求失败" + response);
    }
  },
  (error) => {
    return Promise.reject("请求失败" + error);
  }
);

export default instance;